
define(function(require, exports, module) {
    var component = {};
    component.vue = function(params) {
        var vm = new Vue({
        el: '#component_card_content',
        data: {
            items: [],
            store:{},
            loading:0,
            title:'',
            page:1,
            status:0,
            lastpage:0,
            commission_money:'',
            nodata:0
        },
        created: function() {
             // console.log(params);
             this.getList();
        },
         mounted: function() {
              if (this.mounted == 1) {
                        return;
                    }
                    
                var that = this ;
                app.pager("#component_card",function(){
                   that.getList();
                });
                this.mounted = 1;
        },
        methods: {
            useCard: function(code,title) {
                params.success?params.success({
                    card_code:code,
                    card_title:title,
                }):'';
                
            },
             setStatus:function(status){
                    // var status = $(e.target).attr("data-status");

                    if (this.status === status){
                      return ;
                    }
                      // console.log(status);
                    this.status  = status;
                     
                    this.getList(1);
                   
                },  
                goBack:function(){
                  console.log("123");
                  
                   window.history.back();
                },
                
                getList:function(reload){
                    var that = this;
                    if(reload==1){
                       this.page=1;
                       this.lastpage=0;
                       this.items=[];
                       this.nodata=0;
                     }
                    if( that.loading == 1){
                        return ;
                     }
                     if(this.lastpage==1){
                        return ;
                     }
                     

                     that.loading = 1;      
                    var user_info =  app.getUserInfo();      
                    app.get("api/user_card/get", {
                      page:this.page,
                      status:this.status,
                      limit:50
                    }, function (res) {
                      that.loading = 0;
                      if (res.code != 200) {
                         app.alert(res.msg);
                         return ;
                      }
                      if(res.data.list.length ===0){
                        that.lastpage=1;
                      }
                      that.page++;
                      that.items=that.items.concat(res.data.list);
                      if(that.items.length===0){
                        that.nodata=1;
                      }else{
                        that.nodata=0;
                      }
                      
                      
                    });
                }
        }
        });
        return vm;
    };
    
  module.exports = component;

});